from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
import time

try:
    # 创建Chrome选项实例
    options = Options()
    # 使用options参数启动Chrome浏览器
    driver = webdriver.Chrome(options=options)
    # 访问指定的网址
    driver.get('https://www.ccgp-chongqing.gov.cn/info-notice/procument-notice')
    time.sleep(3)
    input_element = driver.find_element(By.CSS_SELECTOR,"input.form-control.ng-valid.ng-dirty[name='title']")
    # 输入文本
    input_element.send_keys('物业')  # 替换为你想输入的查询文本
    # 模拟按下回车键
    input_element.send_keys(Keys.RETURN)

except Exception as e:
    print(f"An error occurred: {e}")
finally:
    # 确保浏览器被关闭
    print("访问成功")
    # driver.quit()

